home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
ste
/
sam_seq.lzh
/
SAM_SEQ
/
BASICS
/
GFA
/
GFADEMO.LST
next >
Wrap
File List
|
1993-01-04
|
12KB
|
217 lines
Rem ***************************************************************************
Rem * Simple Sequence Demo for GFA Basic *
Rem * by I.Hancock- PHAZE Shift Inc. *
Rem ***************************************************************************
Rem * Reserve memory for code & sequence (& if wanted alternate mixes) *
Rem * & allocate addresses for each. Seq% should be dimensioned to the desktop*
Rem * size in bytes of your sequence file. You can have as many alternative *
Rem * mixes as you like and should dimension each array to DT size in bytes. *
Rem * Mc% is the Machine Code to play the sequence and MUST be included. *
Rem * These arrays are where you will load the files into memory. *
Rem ***************************************************************************
Dim Mc%(1000),Seq%(400000),Amix%(2000)
Code%=Varptr(Mc%(0))
Sequence%=Varptr(Seq%(0))
Mix%=Varptr(Amix%(0))
Finish%=1
C_down%=1
Rem ***************************************************************************
Rem * Code% and Sequence% and Mix% are the relevent start addresses. *
Rem * Finish% is a variable passed to the machine code routine. It is *
Rem * incremented every time a sample is played from the sequence or mix and *
Rem * set to zero when the sequence or mix finish (after all loops). *
Rem * C_down% is another passed variable. It counts down each loop. *
Rem ***************************************************************************
Rem * Load machine code *
Rem ***************************************************************************
Print "Loading Code..."
Bload "a:sam_seq\basics\gfa\SEQUENCE.BIN",Code%
Rem ***************************************************************************
Rem * Define CALL addresses *
Rem ***************************************************************************
Play%=Code%+140
Halt%=Code%+250
Rem ***************************************************************************
Rem * Play% and Halt% are the start addresses of the machine code routines. *
Rem * Do NOT use call Halt% until after you have called Play% at least once *
Rem ***************************************************************************
Rem * Define storage offsets *
Rem ***************************************************************************
Seqstart%=Code%+28
Fin%=Code%+32
Ever%=Code%+36
Anothermix%=Code%+40
Rem ***************************************************************************
Rem * Seqstart% is the address to which you must write the start address of *
Rem * the sequence. You MUST always have a sequence even if you only use the *
Rem * mixes. Since the *.SEQ file contains the samples to be used by the mix. *
Rem * *.MIX files only contain the order of play information, this is why they*
Rem * are alot smaller. Using a MIX file which is not correct for the current *
Rem * sequence may CRASH the computer. To be sure a MIX file will work with a *
Rem * sequence:- load the sequence into my sequencing program, then load *
Rem * the MIX file. If the MIX file loads then it IS OK. *
Rem * Fin% is the address to which you must write the address of your Finish% *
Rem * flag.: Ever% is the address to which your must write the address of your*
Rem * C_down variable.(count down) mode. *
Rem * Anothermix% is the address to which must write the start address of *
Rem * a separate mix. *
Rem ***************************************************************************
Rem * Load sequence into memory *
Rem ***************************************************************************
Print "Loading Sequence."
Bload "a:\sam_seq\sequence.s\tryme.SEQ",Sequence%
Print "Loading Mix."
Bload "a:\sam_seq\sequence.s\mono_2.MIX",Mix%
Rem ***************************************************************************
Rem * Poke Sequence data into code *
Rem ***************************************************************************
Lpoke Seqstart%,Sequence%
Lpoke Fin%,Varptr(Finish%)
Lpoke Ever%,Varptr(C_down%)
Lpoke Anothermix%,0
On Break Gosub Sam_stop
On Error Gosub Sam_stop
Rem ***************************************************************************
Rem * The On Error and On Break commands try to ensure you do not stop a prog.*
Rem * While a sequence is playing. The sub-routine sam_stop checks Finish% *
Rem * If it is 0 then it assumes no seq. is playing, else it calls Halt% *
Rem * NOTE: if you stop a program while a sequence is playing itis VERY likely*
Rem * to crash GFA basic rather severely - YOU HAVE BEEN WARNED *
Rem ***************************************************************************
Rem * The 1st Lpoke puts the start address of the sequence into the Machine - *
Rem * -code. The second puts the address of your Finish% flag variable into MC*
Rem * The MC will count Finish% up each time it plays another sample from the *
Rem * sequence/mix. It is finally set to zero when the seq/mix has finished. *
Rem * It is set to 1 at the start of each loop and NEVER goes to zero when in *
Rem * infinite loop mode.(for obvious reasons - it never finishes! *
Rem * The third Lpoke puts the address of your C_down% (count down) variable *
Rem * into the MC. The MC will count C_down% down to zero - when the looping *
Rem * will stop. You can change the value of either of the prev. 2 variables *
Rem * HOWEVER if Finish% counts above $FFFFFFFF it will reset to zero which *
Rem * your program may see as sequence finished ! NOTE: setting Finish% to 0 *
Rem * will NOT stop the sequence. The MC ONLY counts Finish% for your benefit *
Rem * If you set C_down% to zero during or before a sequence is playing then *
Rem * infinite mode is engaged. In the same way setting it to 1 will make it *
Rem * stop at the end of the current loop. Since the MC treats both variables *
Rem * un-signed using negative no.s will be equivalent to using V. High posit.*
Rem * no.s. *
Rem * I DO NOT ADVISE USING NEGATIVE NUMBERS !! *
Rem * The final Lpoke tells the MC to use (all of) the sequence and not a sep.*
Rem * mix. Changing either the 1st or last Lpoke while a sequence is playing *
Rem * will have NO effect since they are only used to initialise. You MUST *
Rem * STOP the current sequence, re-poke the values, then call Play% again. *
Rem ***************************************************************************
Rem * Now REPLAY the sequence Once *
Rem ***************************************************************************
Lpoke Anothermix%,0
Finish%=1
C_down%=1
Call Play%
Rem
Rem ** 4 commands start the sequence (ALL MODE, not using mix) **
Rem ** Below ⇩ waits for it to stop. **
Rem ** and checks for key press **
Rem
Print "Play once first.."
Pause 50
While Finish%<>0
Print "Still working with Music in background ";
K$=Inkey$
If K$=" " Then
Call Halt%
Print
Print
Print "Last sample playing was (finish% - 1) = ";Finish%-1
Finish%=0
Endif
Wend
Pause 100
Rem ***************************************************************************
Rem * Now REPLAY the sequence 5 Times *
Rem * It IS IMPORTANT that the previous sequence was Halted before the next *
Rem ***************************************************************************
Lpoke Anothermix%,Mix%
Finish%=1
C_down%=5
Call Play%
Rem
Rem ** Anothermix% is sent the address of the mix **
Rem ** And C_down% is set to loop 5 times **
Rem
Print
Print